import "./style.css";
import "@univerjs/design/lib/index.css";
import "@univerjs/ui/lib/index.css";
import "@univerjs/docs-ui/lib/index.css";
import "@univerjs/sheets-ui/lib/index.css";
import "@univerjs/sheets-formula-ui/lib/index.css";

import "@univerjs/sheets-ui/facade";
import "@univerjs/sheets/facade";
import "@univerjs/ui/facade";
import "@univerjs/docs-ui/facade";
import "@univerjs/engine-formula/facade";
import "@univerjs/sheets-formula/facade";
import "@univerjs-pro/exchange-client/facade";

// import { UniverLicensePlugin } from "@univerjs-pro/license";
import {
	Univer,
	LocaleType,
	Tools,
	FUniver,
	UniverInstanceType
} from "@univerjs/core";
import { defaultTheme } from "@univerjs/design";
import { UniverDocsPlugin } from "@univerjs/docs";
import { UniverDocsUIPlugin } from "@univerjs/docs-ui";
import { UniverFormulaEnginePlugin } from "@univerjs/engine-formula";
import { UniverRenderEnginePlugin } from "@univerjs/engine-render";

import { UniverSheetsCustomMenuPlugin } from "./plugins/UniverSheetsCustomMenuPlugin";
import {
	UniverSheetsPlugin
} from "@univerjs/sheets";

import { UniverSheetsFormulaPlugin } from "@univerjs/sheets-formula";
import { UniverSheetsFormulaUIPlugin } from "@univerjs/sheets-formula-ui";
import { UniverSheetsUIPlugin } from "@univerjs/sheets-ui";
import { UniverUIPlugin } from "@univerjs/ui";
import ExchangeClientZhCN from "@univerjs-pro/exchange-client/locale/zh-CN";

import DesignZhCN from "@univerjs/design/locale/zh-CN";
import UIZhCN from "@univerjs/ui/locale/zh-CN";
import DocsUIZhCN from "@univerjs/docs-ui/locale/zh-CN";
import SheetsZhCN from "@univerjs/sheets/locale/zh-CN";
import SheetsUIZhCN from "@univerjs/sheets-ui/locale/zh-CN";
import SheetsFormulaUIZhCN from "@univerjs/sheets-formula-ui/locale/zh-CN";

const univer = new Univer({
	theme: defaultTheme,
	locale: LocaleType.ZH_CN,
	locales: {
		[LocaleType.ZH_CN]: Tools.deepMerge(
			SheetsZhCN,
			DocsUIZhCN,
			SheetsUIZhCN,
			SheetsFormulaUIZhCN,
			UIZhCN,
			DesignZhCN,
			ExchangeClientZhCN
		),
	},
});


// core plugins
univer.registerPlugin(UniverRenderEnginePlugin);
univer.registerPlugin(UniverFormulaEnginePlugin);
univer.registerPlugin(UniverUIPlugin, {
	container: 'app',
});

// doc plugins
univer.registerPlugin(UniverDocsPlugin, {
	hasScroll: false,
});
univer.registerPlugin(UniverDocsUIPlugin);

// sheet plugins
univer.registerPlugin(UniverSheetsPlugin);
univer.registerPlugin(UniverSheetsUIPlugin);
univer.registerPlugin(UniverSheetsFormulaPlugin);
univer.registerPlugin(UniverSheetsFormulaUIPlugin);
univer.registerPlugin(UniverSheetsCustomMenuPlugin);

// create workbook instance
const workbook = univer.createUnit(UniverInstanceType.UNIVER_SHEET, {
	"id": "gyI0JO",
	"sheetOrder": [
		"RSfWjJFv4opmE1JaiRj80"
	],
	"name": "",
	"locale": "zhCN",
	"styles": {},
	"sheets": {
		"RSfWjJFv4opmE1JaiRj80": {
			"id": "RSfWjJFv4opmE1JaiRj80",
			"name": "sheet1",
			"tabColor": "",
			"hidden": 0,
			"rowCount": 20,
			"columnCount": 7,
			"zoomRatio": 1,
			"freeze": {
				"startRow": -1,
				"startColumn": -1,
				"ySplit": 0,
				"xSplit": 0
			},
			"scrollTop": 0,
			"scrollLeft": 0,
			"defaultColumnWidth": 100,
			"defaultRowHeight": 30,
			"mergeData": [],
			"cellData": {},
			"rowData": {},
			"columnData": {

			},
			"showGridlines": 1,
			"rowHeader": {
				"width": 46,
				"hidden": 0
			},
			"columnHeader": {
				"height": 20,
				"hidden": 0
			},
			"selections": [
				"A1"
			],
			"rightToLeft": 0
		}
	},
	"resources": [
		{
			"name": "SHEET_DEFINED_NAME_PLUGIN",
			"data": ""
		}
	]
}
);
const univerAPI = FUniver.newAPI(univer);


const sheet = univerAPI.getActiveWorkbook().getActiveSheet();
const range = sheet.getRange(1, 1, 2, 2);
setTimeout(() => {
  const rect = range.getCellRect(); // width、heigh、left、right、top、bottom、x、y
  console.log(rect);
}, 1000);